﻿<!--
	========================================================================
	 awzBoxes Library
	
	 Homepage: http://www.awzhome.de/
	========================================================================
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of awzBoxes Library.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2011-2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	========================================================================
-->

<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:box="clr-namespace:AWZhome.awzBoxes"
	xmlns:boxt="clr-namespace:AWZhome.awzBoxes.Tools">

	<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

	<!-- Style of the inner control container -->
	<Style x:Key="FloatingBoxItemContainerStyle" TargetType="{x:Type Grid}">
		<Setter Property="Background" Value="{x:Static SystemColors.ControlBrush}" />
		<Setter Property="Margin" Value="0,0,0,0" />
	</Style>

	<!-- Style for auto-hide title buttons -->
	<Style
		x:Key="FloatingWindowTitleButtonStyle" TargetType="{x:Type Button}"
		BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">

		<Setter Property="VerticalAlignment" Value="Center" />
		<Setter Property="HorizontalAlignment" Value="Right" />
		<Setter Property="Width" Value="16" />
		<Setter Property="Height" Value="16" />
		<Setter Property="Padding" Value="0,0,0,0" />
		<Setter Property="Focusable" Value="False" />
		<Setter Property="Foreground" Value="{x:Static SystemColors.ActiveCaptionTextBrush}" />
		<Setter Property="Margin" Value="0,0,0,0" />
		<Setter Property="Padding" Value="0,0,0,0" />
		<Setter Property="FontFamily" Value="Marlett" />
		<Style.Triggers>
			<MultiDataTrigger>
				<MultiDataTrigger.Conditions>
					<Condition Binding="{Binding IsHighlighted}" Value="True" />
					<Condition Binding="{Binding IsLocallyActive}" Value="False" />
				</MultiDataTrigger.Conditions>
				<Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
			</MultiDataTrigger>
		</Style.Triggers>
	</Style>
	
	<Style
		x:Key="FloatingWindowRedockTitleButtonStyle" TargetType="{x:Type Button}"
		BasedOn="{StaticResource FloatingWindowTitleButtonStyle}">
		
		<Setter Property="FontFamily" Value="Wingdings" />
	</Style>
	
	<!-- Special style of window state title button -->
	<Style
		x:Key="FloatingWindowStateTitleButtonStyle" TargetType="{x:Type Button}"
		BasedOn="{StaticResource FloatingWindowTitleButtonStyle}">
		<Style.Triggers>
			<DataTrigger
				Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type box:FloatingWindow}}, Path=WindowState}"
				Value="Maximized">
				<Setter Property="Content" Value="2" />
			</DataTrigger>
			<DataTrigger
				Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type box:FloatingWindow}}, Path=WindowState}"
				Value="Normal">
				<Setter Property="Content" Value="1" />
			</DataTrigger>
		</Style.Triggers>
	</Style>

	<!-- Style of the title bar of floating window -->
	<Style TargetType="{x:Type Label}" x:Key="FloatingWindowTitleStyle">
		<Setter Property="Foreground" Value="{x:Static SystemColors.ActiveCaptionTextBrush}" />
		<Setter Property="HorizontalContentAlignment" Value="Stretch" />
		<Setter Property="VerticalContentAlignment" Value="Stretch" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Label}">
					<Border Background="{x:Static SystemColors.ActiveCaptionBrush}">
						<Grid Margin="2,2,2,2">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="7" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
							</Grid.ColumnDefinitions>
							<ContentPresenter
								Grid.Column="0"
								HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
								VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
								RecognizesAccessKey="True" />
							<Button
								Grid.Column="2"
								Style="{StaticResource FloatingWindowRedockTitleButtonStyle}"
								Visibility="{Binding Path=IsRedockingAllowed, Converter={StaticResource BooleanToVisibilityConverter}}"
								Command="box:BoxCommands.FloatingBoxItemRedock">å</Button>
							<Button
								Grid.Column="3"
								Style="{StaticResource FloatingWindowStateTitleButtonStyle}"
								Command="box:BoxCommands.FloatingBoxItemMaximize"></Button>
							<Button
								Grid.Column="4"
								Style="{StaticResource FloatingWindowTitleButtonStyle}"
								Visibility="{Binding Path=IsClosable, Converter={StaticResource BooleanToVisibilityConverter}}"
								Command="box:BoxCommands.FloatingBoxItemClose">r</Button>
						</Grid>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- Styles of resize thumbs -->
	<Style x:Key="FloatingWindowThumbStyle" TargetType="{x:Type Thumb}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<StackPanel Background="{TemplateBinding Background}" />
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Style.Triggers>
			<DataTrigger
				Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type box:FloatingWindow}}, Path=WindowState}"
				Value="Normal">
				<Setter Property="Visibility" Value="Visible" />
			</DataTrigger>
			<DataTrigger
				Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type box:FloatingWindow}}, Path=WindowState}"
				Value="Maximized">
				<Setter Property="Visibility" Value="Hidden" />
			</DataTrigger>
		</Style.Triggers>
	</Style>

	<Style x:Key="FloatingWindowHorizontalThumbStyle" TargetType="{x:Type Thumb}" BasedOn="{StaticResource FloatingWindowThumbStyle}">
		<Setter Property="Height" Value="3" />
	</Style>

	<Style x:Key="FloatingWindowVerticalThumbStyle" TargetType="{x:Type Thumb}" BasedOn="{StaticResource FloatingWindowThumbStyle}">
		<Setter Property="Width" Value="3" />
	</Style>

	<Style x:Key="FloatingWindowCornerThumbStyle" TargetType="{x:Type Thumb}" BasedOn="{StaticResource FloatingWindowThumbStyle}">
		<Setter Property="Width" Value="3" />
		<Setter Property="Height" Value="3" />
	</Style>

	<!-- Style of FloatingWindow control -->
	<Style TargetType="box:FloatingWindow">
		<Setter Property="WindowStyle" Value="None" />
		<Setter Property="AllowsTransparency" Value="True" />
		<Setter Property="ShowInTaskbar" Value="False" />
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type box:FloatingWindow}">
					<Border Margin="0,0,0,0" CornerRadius="3,3,3,3">
						<Border.Effect>
							<DropShadowEffect Color="LightGray" Opacity=".5" />
						</Border.Effect>
						<Border Margin="5,5,5,5" BorderThickness="1" BorderBrush="DarkGray" CornerRadius="3,3,3,3">
							<Grid>
								<Grid.RowDefinitions>
									<RowDefinition Height="3" />
									<RowDefinition Height="*" />
									<RowDefinition Height="3" />
								</Grid.RowDefinitions>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="3" />
									<ColumnDefinition Width="*" />
									<ColumnDefinition Width="3" />
								</Grid.ColumnDefinitions>

								<Thumb
									x:Name="PART_NWResizeThumb" Grid.Column="0" Grid.Row="0"
									Cursor="SizeNWSE"
									Style="{Binding Source={StaticResource FloatingWindowCornerThumbStyle}}" />
								<Thumb
									x:Name="PART_NResizeThumb" Grid.Column="1" Grid.Row="0"
									Cursor="SizeNS"
									Style="{Binding Source={StaticResource FloatingWindowHorizontalThumbStyle}}" />
								<Thumb
									x:Name="PART_NEResizeThumb" Grid.Column="2" Grid.Row="0"
									Cursor="SizeNESW"
									Style="{Binding Source={StaticResource FloatingWindowCornerThumbStyle}}" />
								<Thumb
									x:Name="PART_WResizeThumb" Grid.Column="0" Grid.Row="1"
									Cursor="SizeWE"
									Style="{Binding Source={StaticResource FloatingWindowVerticalThumbStyle}}" />

								<DockPanel Grid.Column="1" Grid.Row="1" LastChildFill="True">
									<!-- Definition of title bar (for side bars) -->
									<Label
										x:Name="PART_TitleLabel"
										DockPanel.Dock="Top" Style="{StaticResource FloatingWindowTitleStyle}"
										Content="{TemplateBinding Title}"
										AllowDrop="True">
										<Label.InputBindings>
											<MouseBinding
												Gesture="LeftDoubleClick"
												Command="box:BoxCommands.FloatingBoxItemMaximize" />
										</Label.InputBindings>
									</Label>

									<!-- Child container -->
									<ContentPresenter Content="{TemplateBinding Content}" />
								</DockPanel>

								<Thumb
									x:Name="PART_EResizeThumb" Grid.Column="2" Grid.Row="1"
									Cursor="SizeWE"
									Style="{Binding Source={StaticResource FloatingWindowVerticalThumbStyle}}" />
								<Thumb
									x:Name="PART_SWResizeThumb" Grid.Column="0" Grid.Row="2"
									Cursor="SizeNESW"
									Style="{Binding Source={StaticResource FloatingWindowCornerThumbStyle}}" />
								<Thumb
									x:Name="PART_SResizeThumb" Grid.Column="1" Grid.Row="2"
									Cursor="SizeNS"
									Style="{Binding Source={StaticResource FloatingWindowHorizontalThumbStyle}}" />
								<Thumb
									x:Name="PART_SEResizeThumb" Grid.Column="2" Grid.Row="2"
									Cursor="SizeNWSE"
									Style="{Binding Source={StaticResource FloatingWindowCornerThumbStyle}}" />

							</Grid>
						</Border>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>